import os
import sys


g_textConstants = {}
g_textTabIndex = []
g_textConstantIndex = []


#--------------------------------------------------------------------------------------------------------------------------------------------------------------	
#--------------------------------------------------------------------------------------------------------------------------------------------------------------
def WriteStringConstantsToDataType(outputFile):

	file = open(outputFile, "w")
	
	for tab in g_textConstantIndex:
		for constant in g_textConstantIndex[g_textConstantIndex.index(tab)]:
			file.write(g_textConstants[constant] + " = \"" + constant + "\"\n")
			
	file.close()

#--------------------------------------------------------------------------------------------------------------------------------------------------------------	
#--------------------------------------------------------------------------------------------------------------------------------------------------------------
def LoadStringConstantsFromJava(inputFile):
	file = open(inputFile)
	
	global g_textConstants
	global g_textTabIndex
	global g_textConstantIndex
	
	for line in file:
		if line.strip().startswith("//-------------------------------------------------------------------------"):
			g_textTabIndex.append(line.strip().split(" ")[1])
			g_textConstantIndex.append([])
			
		if line.strip().startswith("final static int"):
			constant = line.replace("final static int",'').replace(' ','').strip().strip(';').split('=')
			
			if constant[0].strip() == "GAME_NB_STRINGS":
				global g_gameNbStrings
				g_gameNbStrings = int(constant[1])
			else:
				g_textConstants[constant[0].strip()] = constant[1].strip()
				g_textConstantIndex[-1].append(constant[0].strip())
	file.close()

	
	
#--------------------------------------------------------------------------------------------------------------------------------------------------------------	
#--------------------------------------------------------------------------------------------------------------------------------------------------------------
# Main 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------	
def main(argv = sys.argv):

	print argv[1]
	print argv[2]
	
	LoadStringConstantsFromJava(argv[1])	
	WriteStringConstantsToDataType(argv[2])
	
#--------------------------------------------------------------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------------------------------------------------------------------

if __name__ == "__main__":
	ret = main()
	sys.exit(ret)